package com.app.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author by zxy
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private Integer code;
    private  Map<String,Object> datamap=new HashMap<>();
    private  Object data;
    public static  Result success(){                    //请求成功
        Result result=new Result();
        result.setCode(200);
        return result;
    }
    public static  Result success(Object data){
        Result result=new Result();
        result.setCode(200);
        result.setData(data);
        return result;
    }
    public static Result fail(Object data){
        Result result=new Result();
        result.setCode(500);
        result.setData(data);
        return result;
    }
    public static  Result fail(){
        Result result=new Result();
        result.setCode(500);
        return result;
    }
    public  Result addmessage(String key,Object value){
        this.getDatamap().put(key,value);
        return this;
    }

}
